package com.mall.evaluate.service.impl;

/*
 *  2021/7/15 13:13
 *  @Author  蛋儿
 */

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mall.evaluate.mapper.TbEvaluateMapper;
import com.mall.evaluate.entity.TbEvaluate;
import com.mall.evaluate.service.TbEvaluateService;
import com.mall.evaluate.vo.VoEvaluate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TbEvaluateServiceImpl implements TbEvaluateService {

    @Autowired
    private TbEvaluateMapper evalueateMapper;


    /**
     * 商品评论列表
     * @return
     */
    @Override
    public List<TbEvaluate> findAll() {
        return evalueateMapper.findAll();
    }


    /**
     * 删除商品评论
     * @param id
     */
    @Override
    public void delete(Integer id) {
        evalueateMapper.delete(id);
    }

    /**
     * 添加商品评论
     * @param evaluate
     */
    @Override
    public void addEvaluate(TbEvaluate evaluate) {
        evaluate.setEvaluateTime(new Date());
        evalueateMapper.addEvaluate(evaluate);
    }

    /**
     * @author  XueYingDan
     * @email  409978619@qq.com
     * @date 2021/7/19 11:35
     * @version 1.0
     * 商品评论模糊查询
     */
    @Override
    public PageInfo findMohu(TbEvaluate evaluate, int page, int size) {
        PageHelper.startPage(page,size);
        List<VoEvaluate> mohu = evalueateMapper.findMohu(evaluate);
        return new PageInfo(mohu);
    }


    @Override
    public void reply(Integer id, String replyContent) {
        TbEvaluate tbEvaluate = new TbEvaluate();
        tbEvaluate.setId(id);
        tbEvaluate.setReplyContent(replyContent);
        evalueateMapper.reply(tbEvaluate);
    }


}
